package com.ruoyi.web.controller.laiqianba.applet;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.applet.service.IAppletCountInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AppletCountInfo;
import com.ruoyi.web.wrapper.AppletCountInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公众号二维码统计Controller
 * 
 * @author ruoyi
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/applet/count")
public class AppletCountInfoController extends BaseController
{
    @Autowired
    private IAppletCountInfoService appletCountInfoService;

    /**
     * 查询公众号二维码统计列表
     */
    @PreAuthorize("@ss.hasPermi('applet:count:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletCountInfo appletCountInfo)
    {
        startPage();
        List<Map<String, Object>> list = appletCountInfoService.selectAppletCountInfoMapList(appletCountInfo);
        list = new AppletCountInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出公众号二维码统计列表
     */
    @PreAuthorize("@ss.hasPermi('applet:count:export')")
    @Log(title = "公众号二维码统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletCountInfo appletCountInfo)
    {
        List<AppletCountInfo> list = appletCountInfoService.selectAppletCountInfoList(appletCountInfo);
        ExcelUtil<AppletCountInfo> util = new ExcelUtil<AppletCountInfo>(AppletCountInfo.class);
        util.exportExcel(response, list, "公众号二维码统计数据");
    }

    /**
     * 获取公众号二维码统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('applet:count:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletCountInfoService.selectAppletCountInfoById(id));
    }

    /**
     * 新增公众号二维码统计
     */
    @PreAuthorize("@ss.hasPermi('applet:count:add')")
    @Log(title = "公众号二维码统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletCountInfo appletCountInfo)
    {
        return toAjax(appletCountInfoService.insertAppletCountInfo(appletCountInfo));
    }

    /**
     * 修改公众号二维码统计
     */
    @PreAuthorize("@ss.hasPermi('applet:count:edit')")
    @Log(title = "公众号二维码统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletCountInfo appletCountInfo)
    {
        return toAjax(appletCountInfoService.updateAppletCountInfo(appletCountInfo));
    }

    /**
     * 删除公众号二维码统计
     */
    @PreAuthorize("@ss.hasPermi('applet:count:remove')")
    @Log(title = "公众号二维码统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletCountInfoService.deleteAppletCountInfoByIds(ids));
    }
}
